package xyz.lwm.lazycat.netpipe.common.msgs;

import xyz.lwm.lazycat.netpipe.common.protocol.MsgType;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 消息处理器注入
 *
 * @author lwm
 */
public class MessageHandlerRegistry {

    private final Map<MsgType, MessageHandler> handlers = new ConcurrentHashMap<>();

    public void register(MsgType msgType, MessageHandler handler) {
        handlers.put(msgType, handler);
    }

    public MessageHandler getHandler(MsgType msgType) {
        return handlers.get(msgType);
    }

}
